home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / linuxcon.000 / linuxcon / linuxconf-1.6 / netconf / routed.c < prev    next >
C/C++ Source or Header  |  1996-04-23  |  3KB  |  114 lines

  1. #include "netconf.h"
  2. #include "internal.h"
  3. #include "../misc/misc.h"
  4. #include "../dialog/dialog.h"
  5. #include "netconf.m"
  6.  
  7. NETCONF_HELP_FILE help_routed ("routed");
  8.  
  9. static const char ROUTED_P[]="routed";
  10. static const char REQUIRED[]="required";
  11. static const char GATEWAY[]="gateway";
  12. static const char SILENT[]="silent";
  13.  
  14.  
  15. PUBLIC ROUTED::ROUTED()
  16. {
  17.     /* #Specification: netconf / routed / default operation
  18.         Without configuration, netconf assume that the routed
  19.         daemon is not required.
  20.  
  21.         At this time the routed daemon is reported to be
  22.         broken (it looses routes), so I have decided not
  23.         to run it by default. This should be the reverse
  24.         in the future I guess. Comments ?
  25.     */
  26.     required = linuxconf_getvalnum(ROUTED_P,REQUIRED,0);
  27.     gateway = linuxconf_getvalnum(ROUTED_P,GATEWAY,0);
  28.     silent = linuxconf_getvalnum(ROUTED_P,SILENT,1);
  29. }
  30.  
  31. /*
  32.     Save the configuration in /etc/conf.linuxconf
  33. */
  34. PUBLIC void ROUTED::save()
  35. {
  36.     linuxconf_replace(ROUTED_P,REQUIRED,required);
  37.     linuxconf_replace(ROUTED_P,GATEWAY,gateway);
  38.     linuxconf_replace(ROUTED_P,SILENT,silent);
  39.     linuxconf_save();
  40. }
  41.  
  42. /*
  43.     Should we start routed
  44. */
  45. PUBLIC int ROUTED::is_required()
  46. {
  47.     return required;
  48. }
  49.  
  50. /*
  51.     Set the option of the command line to start routed.
  52. */
  53. PUBLIC void ROUTED::setoptions(char *buf)
  54. {
  55.     buf[0] = '\0';
  56.     /* #Specification: netconf / routed / options
  57.         netconf support only the -s and -g option of routed.
  58.  
  59.         -s stands for silent. This means that routed only listen
  60.         for route, does not publish anything.
  61.  
  62.         -g stands for gateway. Routed will publish its default
  63.         route.
  64.     */
  65.     if (silent){
  66.         strcpy (buf,"-s");
  67.     }else if (gateway){
  68.         strcpy (buf,"-g");
  69.     }
  70. }
  71.  
  72. /*
  73.     Return -1 if the edit was abort
  74. */
  75. PUBLIC int ROUTED::edit()
  76. {
  77.     int ret = -1;
  78.     DIALOG dia;
  79.     dia.newf_chk ("",required,MSG_U(F_ROUTEDREQ,"routed is required"));
  80.     dia.newf_chk ("",silent,MSG_U(F_NOEXPORT,"Does not export any routes (Silent)"));
  81.     dia.newf_chk ("",gateway,MSG_U(F_EXPORTDEFRT,"Export your default route"));
  82.     while (1){
  83.         if (dia.edit(MSG_U(T_ROUTEDCONF,"Routed daemon configuration")
  84.             ,MSG_U(I_ROUTEDCONF
  85.              ,"Check the appropriate options\n"
  86.               "unless you have a simple network, routed\n"
  87.               "is required.\n")
  88.             ,help_routed
  89.             ,0)==MENU_ACCEPT){
  90.             if (silent && gateway){
  91.                 xconf_error (MSG_U(E_CANTSILENT
  92.                     ,"Can't be both silent and a gateway\n"));
  93.             }else{
  94.                 save();
  95.                 ret = 0;
  96.                 break;
  97.             }
  98.         }else{
  99.             break;
  100.         }
  101.     }
  102.     if (ret == -1) dia.restore();
  103.     return ret;
  104. }
  105.  
  106. void routed_edit ()
  107. {
  108.     ROUTED r;
  109.     r.edit();
  110. }
  111.     
  112.     
  113.  
  114.